package arrayInit;


import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.tree.ParseTree;

//测试 arrayInit
public class Test {

    public static void main(String[] args) throws Exception {
        System.out.println("please input tokens to test, using ctrl+d or ctrl+z to end input");
        //charStream from standard input
        CharStream input = CharStreams.fromStream(System.in);
        //词法分析
        ArrayInitLexer lexer = new ArrayInitLexer(input);

        //create a buffer of tokens pulled from the lexer
        CommonTokenStream tokenStream = new CommonTokenStream(lexer);

        //create a parser that feeds off the tokens buffer
        ArrayInitParser parser = new ArrayInitParser(tokenStream);

        //begin parsing at init rule
        ParseTree tree = parser.init();
        System.out.println(tree.toStringTree(parser));

    }
}
